
#ifndef _EPOLL_H_
#define _EPOLL_H_
#include <string> 

typedef struct _Ioevent
{
	int event_type;       //-1:get error,0: connect event,1:io event

	int is_text;          //1:pdata is text,0:pdata is binary
	unsigned char* pdata; // data pointer for io
	int data_len;         // length of pdata
	int pos;              // already send pos in pdata  
	char key[64];         // The unique identifier of this connection
	int fd;

}IoEvent;

using namespace std;

typedef void (*CallBack)(IoEvent* data);
int start_server(int n);
int register_callback(string value, CallBack key);

/***  send data   ****
 ** send data is a Asynchronous event
 ** handler:  second argument of callback function
 ** buff:     data to be send
 ** buff_len: data length to be send
 ** is_text:  0: data is binary
 **           1: data is text
 **
 ** *******************/
int send_data(IoEvent* handler, unsigned char* buff, int buff_len, int is_text);
void send_stop();

#endif
